<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>显示所有车辆</title>
    <link rel="stylesheet" href="https://cdn.staticfile.net/twitter-bootstrap/4.6.2/css/bootstrap.css">
    <style>
        .current{
            color:red;
            font-size: 18px;
            font-weight: bold;
            background-color: yellow;
        }
    </style>
</head>
<body>
<div class="container">
    <div>输入编号：</div>
    <input type="text" class="form-control" style="width: 150px">
    <div>输入车名：</div>
    <input type="text" class="form-control" style="width: 150px">
    <br>
    <button type="submit" class="btn btn-primary">查询车辆</button>
    <div><a href="${pageContext.request.contextPath}/add.jsp" class="btn btn-primary float-right  mr-5 my-3">添加车辆</a></div>
    <table class="table text-center">
        <thead class="thead-dark">
        <tr>
            <th scope="col">编号</th>
            <th scope="col">车名</th>
            <th scope="col">颜色</th>
            <th scope="col">车速</th>
            <th scope="col">生产年份</th>
            <th scope="col">价格</th>
        </tr>
        </thead>
        <tbody>
        <c:forEach var="s" items="${pb.list}">
            <tr>
                <th scope="row">${s.id}</th>
                <td>${s.name}</td>
                <td>${s.color}</td>
                <td>${s.speed}</td>
                <td><fmt:formatDate value="${s.birthday}" pattern="yyyy年MM月dd日"/></td>
                <td>${s.price}</td>
                <td><a href="${pageContext.request.contextPath}/QueryIdServlet?id=${s.id}" class="btn btn-success">更新</a><a href="${pageContext.request.contextPath}/DeleteServlet?id=${s.id}"  class="btn btn-danger mx-2">删除</a></td>
            </tr>
        </c:forEach>
        </tbody>
    </table>
</div>
<nav aria-label="Page navigation example">
    <ul class="pagination justify-content-center">
        <c:if test="${pb.currentPage!=1}">
            <li class="page-item ">
                <a class="page-link" href="${pageContext.request.contextPath}/QueryPageServlet?currentPage=1&rows=${pb.rows}" >第一页</a>
            </li>
            <li class="page-item ">
                <a class="page-link" href="${pageContext.request.contextPath}/QueryPageServlet?currentPage=${pb.previous}&rows=${pb.rows}" >前一页</a>
            </li>
        </c:if>

        <c:forEach begin="${pb.begin}" end="${pb.end}" var="i">
            <c:if test="${pb.currentPage==i}">
                <li class="page-item"><a class="page-link current" href="#" >${i}</a></li>
            </c:if>
            <c:if test="${pb.currentPage!=i}">
                <li class="page-item"><a class="page-link" href="${pageContext.request.contextPath}/QueryPageServlet?currentPage=${i}&rows=${pb.rows}">${i}</a></li>
            </c:if>

        </c:forEach>
        <c:if test="${pb.currentPage!=pb.totalPage}">
            <li class="page-item">
                <a class="page-link" href="${pageContext.request.contextPath}/QueryPageServlet?currentPage=${pb.next}&rows=${pb.rows}">下一页</a>
            </li>
            <li class="page-item">
                <a class="page-link" href="${pageContext.request.contextPath}/QueryPageServlet?currentPage=${pb.totalPage}&rows=${pb.rows}">最后一页</a>
            </li>
        </c:if>

    </ul>
   <%-- 总页数：${pb.totalPage}-----总记录数${pb.totalCount}----每页显示记录数${pb.rows}<br>
    当前页${pb.currentPage} ----前一页${pb.previous}  下一页${pb.next}<br>
    开始页${pb.begin}----结束页${pb.end}--%>
</nav>
</body>
</html>
